<template>
	<ElInputNumber
	  v-model="props.data[props.field.name]"
	  :min="props.field.min"
	  :max="props.field.max"
	  :step="props.field.step"
	  :precision="props.field.precision"
	  style="width: 100%"
	/>
</template>

<script lang="ts" setup>
import { computed, ref, watch } from 'vue'
import type { PropType } from 'vue'

const emit = defineEmits(['update:value'])
const props = defineProps({
  field: {
    type: Object as PropType<Record<string, any>>,
    required: true,
    default: () => ({})
  },
  data: {
    type: Object as PropType<Record<string, any>>,
    default: () => ({})
  },
})

// 计算属性
const placeholderText = computed(() => {
  return props.field.placeholder || `请输入${props.field.label || ''}值`
})

// 双向绑定值
const fieldValue = computed({
  get: () => props.data[props.field.name],
  set: (value) => {
    emit('update:value', value)
  }
})

</script>